#include "Hook_Scaleform.h"

#include <string>
#include <sfse_common/Log.h>
#include <sfse_common/Relocation.h>
#include <sfse_common/Types.h>

#include "my_test/Addresses.h"

RelocAddr<uintptr_t> kHook_Scaleform_Log_Offset(Scaleform_Log_vftable_ADDRESS + 0x08);
void Scaleform_LogMessageVarg(void*/*Scaleform::GFx::Log::State* */ logger, u32 messageType, const char* fmt, va_list args)
{
    std::string prefix = "[Scaleform] ";
    prefix+=fmt;
    DebugLog::log(DebugLog::kLevel_Message, prefix.c_str(), args);
#ifdef _DEBUG
    //char szBuff[1024];
    //vsnprintf_s(szBuff, sizeof(szBuff), fmt, args);
    //strcat_s(szBuff, "\n");
    //OutputDebugString(szBuff);
    #endif
}

#include "sfse_common/SafeWrite.h"
void Hooks_Scaleform_Apply()
{
    safeWrite64(kHook_Scaleform_Log_Offset, (uintptr_t)Scaleform_LogMessageVarg);
}